package com.shansun.ibatis.utils;

import java.util.Collection;

/**
 * @author xujun
 * 
 */
public class Assert {
	private static final String NO_MESSAGE = "";

	public static void assertTrue(boolean val) {
		assertTrue(val, NO_MESSAGE);
	}

	public static void assertTrue(boolean val, String message) {
		if (val) {
			fail(message);
		}
	}

	public static void assertNull(Object val) {
		assertNull(val, NO_MESSAGE);
	}

	public static void assertNull(Object val, String message) {
		if (val == null) {
			fail(message);
		}
	}

	public static void assertEmpty(Collection<?> val) {
		assertEmpty(val, NO_MESSAGE);
	}

	public static void assertEmpty(Collection<?> val, String message) {
		if (val == null || val.size() == 0) {
			fail(message);
		}
	}

	static void fail(String message) {
		throw new IllegalArgumentException(message);
	}
}
